package easy;

public class Solution_1863 {

    public int subsetXORSum(int[] nums) {
        int sum = 0;
        int length = 1 << nums.length;
        for (int i = 0; i < length; i++) {
            int j = i, index = 0, val = 0;
            while (j > 0) {
                if (j % 2 == 1) {
                    val ^= nums[index];
                }
                j >>= 1;
                index++;
            }
            sum += val;
        }
        return sum;
    }

    public static void main(String[] args) {
        Solution_1863 model = new Solution_1863();
        System.out.println(model.subsetXORSum(new int[]{1, 3}));
        System.out.println(model.subsetXORSum(new int[]{5, 1, 6}));
    }
}
